﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using BussinesLogic;
using System.Collections;

namespace DataAccess.Factory
{
    class LineaFactoryDao : BaseFactory
    {

        public LineaFactoryDao()
        {
            this.classType = typeof(Linea);
        }

        private string uspGetLinea = @"fd_Linea_get_Linea";
        private string uspGetLineasByFolio = @"fd_Linea_gets_by_folio";

        /* funciones */

        public ArrayList getLineasByFolio(int numFolio, string numExpediente, string codDocumento)
        {
            SqlParameter[] parameter = new SqlParameter[3];

            parameter[0] = new SqlParameter("@NumFolio", numFolio);
            parameter[1] = new SqlParameter("@NumExpediente", numExpediente);
            parameter[2] = new SqlParameter("@CodDocumento", codDocumento);

            ArrayList obj = this.DataTableToObjectList(parameter, this.uspGetLineasByFolio);

            if (obj != null && obj.Count > 0)
            {
                return obj;
            }
            else
            {
                return null;
            }

        }

        public Linea getLinea(int numLinea, int numFolio, string NoExpediente, string codDocumento)
        {
            SqlParameter [] parameter = new SqlParameter[4];

            parameter[0] = new SqlParameter("@numLinea", numLinea);
            parameter[1] = new SqlParameter("@numFolio", numFolio);
            parameter[2] = new SqlParameter("@NoExpediente", NoExpediente);
            parameter[3] = new SqlParameter("@codDocumento", codDocumento);

            ArrayList obj = this.DataTableToObjectList(parameter, this.uspGetLinea);

            if (obj != null && obj.Count > 0)
            {
                return (Linea)obj[0];
            }
            else
            {
                return null;
            }
            
        }
    }
}
